
Chapter 34. GPS Mapping and Geotagged Images : JMapViewer Tests

From the website:

  Killer Game Programming in Java
  http://fivedots.coe.psu.ac.th/~ad/jg

  Dr. Andrew Davison
  Dept. of Computer Engineering
  Prince of Songkla University
  Hat yai, Songkhla 90112, Thailand
  E-mail: ad@fivedots.coe.psu.ac.th


If you use this code, please mention my name, and include a link
to the website.

Thanks,
  Andrew

============================

Topics: displaying a dynamic OpenStreetMaps (OSM) map in
        an application; updating the map with GPS data;
        creating large images from OSM map tiles.

Directory contents:

There are 4 Java files:
  * ShowMap.java
  * ShowGPS.java
  * GeoMath.java
    This class is duplicated in 3 folders -- 
       in JMapViewer Tests/, Panoramio Search/, and Geotagging/
  * StitchTiles.java

One log4j file:
   * log4j.properties
       - this switches off log4j which is otherwise
         called by gpsinput when ShowGPS is run

There are 2 batch files:
  * compile.bat
  * run.bat
  - both batch files assume:
    * JMapViewer is installed in c:\JMapViewer\

    * gpsylon is installed in c:\gpsylon_bin-0.5.3\
      (this is only used by the ShowGPS example)

    * RXTX and its Windows DLLs are installed in c:\rxtx\
      (this is only used by the ShowGPS example)

----------------------------
Compilation:

  > compile *.java

----------------------------
Execution:

  > run ShowMap <latitude> <longitude>
e.g.
  > run ShowMap 7.006835 100.502
  

  > run ShowGPS <serial_port_name>
e.g.
  > run ShowGPS COM3


  > run StitchTiles <latitude> <longitude>
e.g.
  > run StitchTiles 7.006835 100.502
 

----------------------------
Hardware

For the GPS-related examples, you will need a USB GPS
receiver which can receive NMEA messages, and whose 
driver makes it appear to be a serial port.
e.g.
  the Canmore GT-730F USB GPS receiver
  http://www.canmore.com.tw/

----------------------------
RXTX Installation
   http://www.rxtx.org/

I downloaded rxtx 2.1-7r2 (stable) for Windows:
  rxtx-2.1-7-bins-r2.zip

I unzipped it and created a folder c:\rxtx containing:
  * RXTXcomm.jar
  * rxtxSerial.dll
  * rxtxParallel.dll

----------------------------
GPSylon Installation
  http://www.tegmento.org/gpsylon/
  http://sourceforge.net/projects/gpsmap/files/  (for downloads)

I downloaded the latest GPSylon binary and source code:
   * gpsylon_bin-0.5.3.zip   (binary)
   * gpsylon_src-0.5.3.zip   (source; contains API docs)

I unzipped gpsylon_bin-0.5.3.zip into c:\gpsylon_bin-0.5.3\

----------------------------
JMapViewer Installation
  http://wiki.openstreetmap.org/wiki/JMapViewer
  http://svn.openstreetmap.org/applications/viewer/jmapviewer  
     (SVN repository for downloads)

I used a SVN client to download:
   * build.xml   (an ANT build file)
   * src/   (source, with correct folder structure)


A good Windows SVN client: TortoiseSVN, http://tortoisesvn.net
Apache ANT: http://ant.apache.org/

Install Apache ANT then execute the build.xml file:
  > ant all

This will create three JAR files in bin/:
  * JMapViewer.jar
  * JMapViewer_Demo.jar     // double click this for a demo
  * JMapViewer_src.jar

I moved these to c:\JMapViewer\

If you want the API docs, you need to add an extra command
to build.xml:

	<target name="create_docs">
		<javadoc  destdir="docs">
		<packageset dir="src" defaultexcludes="yes">
			<include name="org/openstreetmap/gui/jmapviewer/**"/>
		</packageset>
		</javadoc>
	</target>

Then call:
  > ant create_docs

The documentation will appear in docs/

---------
Last updated: 8th November 2010
